package main

import (
	"fmt"
	"math"
)

type Point struct {
	X, Y float64
}

func (p *Point) MoveTo(x float64, y float64) {
	p.X, p.Y = x, y
}

func (p Point) Distance(q Point) float64 {
	return math.Hypot(q.X-p.X, q.Y-p.Y)
}

func (p Point) Show() {
	fmt.Printf("Position{%v, %v}\n", p.X, p.Y)
}

type Circle struct {
	Radius float64
	*Point
}

/*
func (c Circle) Show() {
	fmt.Printf("Position{%v, %v} radius:%v\n", c.X, c.Y, c.Radius)
}
*/

func main() {
	fmt.Println("--------- test 1 ----------")
	p := Point{}
	p.Show()
	p.MoveTo(10.5, 20.3)
	p.Show()

	fmt.Println("--------- test 2 ----------")
	// c := Circle{10.5, &Point{}}
	c := Circle{Radius: 10.5}
	c.Show()
	c.MoveTo(4.5, 3.6)
	c.Show()

	fmt.Println("--------- test 2 ----------")
	dist := c.Distance(p)
	fmt.Printf("dist(c, p) = %v\n", dist)

	d := Circle{0, &Point{}}
	dist = c.Distance(*d.Point) // c.Distance(d) // not ok!
	fmt.Printf("dist(c, d) = %v\n", dist)
}
